<?php


namespace App\Http\Controllers\Api;

use App\Businesses\BusinessState;

use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Services\Business\Models\Reward;
use App\Http\Requests\ApiV2\RewardRequest;
use App\Services\Member\Services\UserService;
use App\Services\Member\Interfaces\UserServiceInterface;

class RewardController extends BaseController
{



    /**
     * @var UserService
     */
    protected $userService;
    protected $businessState;


    public function __construct(


        UserServiceInterface      $userService,
        BusinessState             $businessState


    )
    {

        $this->userService = $userService;
        $this->businessState = $businessState;


    }


    /**
     *暂时通过名字来查询，同步socialite跟企业外部联系的数据
     */
    public function store(RewardRequest $request, Reward $reward)
    {


        $reward->fill($request->filldata())->save();
        return $this->success(__('插入成功'));
    }

    public function edit(RewardRequest $request, $id)
    {

        $reward = Reward::query()->where('id', $id)->firstOrFail();
        return $this->successData(compact('reward'));
    }


    public function delete(Request $request, $id)
    {

        Reward::destroy($id);
        return $this->success(__('删除成功'));
    }

    public function update(RewardRequest $request, $id)
    {

         $reward = Reward::query()->where('id', $id)->firstOrFail();
        $reward->fill($request->filldata())->save();
        return $this->success(__('更新成功'));
    }



    public function detail($id)
    {

        $reward = Reward::query()
            ->where('id', $id)->firstOrFail();
        return $this->successData(compact('reward'));
    }


}
